import { Column, CreateDateColumn, Entity, Index, ManyToMany, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm';
import { Article } from '../../articles/entities/article.entity';
import { Content } from "../../content/entities/content.entity";

@Entity()
@Index(['label'])
export class Tag {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({ type: 'varchar', length: 128, comment: '标签名', unique: true })
  label: string;

  @Column({ type: 'int', default: 0, comment: '排序优先级 越小越前' })
  sort: number;

  @ManyToMany(() => Article, (article) => article.tags)
  articles: Article[];

  @ManyToMany(() => Content, (content) => content.tags)
  contents: Content[];

  @CreateDateColumn()
  createTime: Date;

  @UpdateDateColumn()
  updateTime: Date;
}
